fn warn_bad_override(&self,
override_summary: &Summary,
real_summary: &Summary) -> CargoResult<()> {
- let real = real_summary.package_id();
- // If we don't have a locked variant then things are going quite wrong
- // at this point, but we've already emitted a warning, so don't worry
- // about it.
- let map = match self.locked.get(real.source_id()) {
- Some(map) => map,
- None => return Ok(()),
- };
- let list = map.get(real.name()).chain_error(|| {
- human(format!("failed to find lock name of {}", real))
- })?;
- let &(_, ref real_deps) = list.iter().find(|&&(ref id, _)| {
- real == id
- }).chain_error(|| {
- human(format!("failed to find lock version of {}", real))
- })?;
- let mut real_deps = real_deps.clone();
+ let mut real_deps = real_summary.dependencies().iter().collect::<Vec<_>>();
let boilerplate = "\
This is currently allowed but is known to produce buggy behavior with spurious
";
for dep in override_summary.dependencies() {
- if let Some(i) = real_deps.iter().position(|id| dep.matches_id(id)) {
+ if let Some(i) = real_deps.iter().position(|d| dep == *d) {
real_deps.remove(i);
continue
}
assert_that(p.cargo_process("build"),
execs().with_status(0));
}
+
+#[test]
+fn paths_ok_with_optional() {
+ Package::new("bar", "0.1.0").publish();
+
+ let p = project("local")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "local"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ foo = { path = "foo" }
+ "#)
+ .file("src/lib.rs", "")
+ .file("foo/Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [dependencies]
+ bar = { version = "0.1", optional = true }
+ "#)
+ .file("foo/src/lib.rs", "")
+ .file("foo2/Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [dependencies]
+ bar = { version = "0.1", optional = true }
+ "#)
+ .file("foo2/src/lib.rs", "")
+ .file(".cargo/config", r#"
+ paths = ["foo2"]
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(0).with_stderr("\
+[COMPILING] foo v0.1.0 ([..]foo2)
+[COMPILING] local v0.0.1 ([..])
+[FINISHED] [..]
+"));
+}
+
+#[test]
+fn paths_add_optional_bad() {
+ Package::new("bar", "0.1.0").publish();
+
+ let p = project("local")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "local"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ foo = { path = "foo" }
+ "#)
+ .file("src/lib.rs", "")
+ .file("foo/Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("foo/src/lib.rs", "")
+ .file("foo2/Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [dependencies]
+ bar = { version = "0.1", optional = true }
+ "#)
+ .file("foo2/src/lib.rs", "")
+ .file(".cargo/config", r#"
+ paths = ["foo2"]
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(0).with_stderr_contains("\
+warning: path override for crate `foo` has altered the original list of
+dependencies; the dependency on `bar` was either added or\
+"));
+}